#include <iostream>
#include <future>
using namespace std;

int func() {
    int i = 0;
    for(i=0;i<1000;i++)
        i++;
    return i;
}

int main()
{
    //future<int> ret=async(launch::async, func);
    packaged_task<int()> task(func);
    auto ret=task.get_future();

    thread t1(move(task));

    cout<<func()<<endl;
    t1.join();
    cout<<ret.get()<<endl;
}